package pages;

import org.openqa.selenium.By;
import utils.Log4Test;

/**
 * Created by Mikhail.Chub on 05/06/2014.
 */
public class ComparisonPage extends BasePage{

    protected static final String PRODUCT_FOUND_LOCATOR = "//a[contains(text(),'%s')]";
    protected static final String COMPARISON_PAGE_URL = "comparison";

    public ComparisonPage (PageManager pageManager) {
        super(pageManager);
    }

    public boolean isProductFound(String productName) {
        boolean found = driver.findElement(By.xpath(String.format(PRODUCT_FOUND_LOCATOR, productName))).isDisplayed();
        if (found) {Log4Test.info("Product '" + productName + "' is found");}
        else {Log4Test.error("Product '" + productName + "' is not found!");}
        return found;
    }

    public boolean isOpened() {

        String currentUrl = driver.getCurrentUrl();
        boolean opened = currentUrl.contains(COMPARISON_PAGE_URL);
        if (opened) {Log4Test.info("Comparison page is opened");}
        else {Log4Test.error("Comparison page is not opened!");}
        return opened;
    }
}
